var app = new Vue({
    el: '#app',
    computed:{
        totalPrice: function (){
            let totalValue = 0
            for (const li of this.list){
                totalValue += li.price * li.count
            }
            return totalValue
        }
    },
    data: {
        list: [
            {
                id: 1,
                name: 'iphone 7',
                price: 6188,
                count: 1
            },
            {
                id: 2,
                name: 'iphone 11',
                price: 6888,
                count: 1
            },
            {
                id: 3,
                name: 'iphone 12',
                price: 7000,
                count: 1
            }
        ]
    },
    methods: {
        handleReduce: function (index){
            this.list[index].count -= 1
        },
        handleAdd: function (index){
            this.list[index].count += 1
        }

    }
});
